<?php if (!defined('THINK_PATH')) exit();?><div class="row">
    <div class="top">业务部>GPS待分配列表</div>
    <div class="content applylist">
        <div class="box">
            <h1>GPS待分配列表</h1>
            <div class="list-block">
                <div class="row">
                    <table class="list">
                        <tr>
                            <th>申请人</th> <th>银行</th><th>银行卡</th> <th>垫资时间</th> <th>备注</th><th>操作</th>
                        </tr>
                        <?php if(is_array($advanceList)): foreach($advanceList as $key=>$_v): ?><tr>
                            <td><?php echo ($_v["user_name"]); ?></td>
                            <td><?php echo ($_v["bank_name"]); ?></td>
                            <td><?php echo ($_v["bank_card"]); ?></td>
                            <td><?php echo (date('Y-m-d H:i:s', $_v["add_time"])); ?></td>
                            <td>备注</td>
                            <td>
                                <a class="btn btn-primary" href="<?php echo U('GPS/addEquip?user_id='.$_v['user_id']);?>">添加GPS设备</a>&nbsp;&nbsp;
                                <button data-id=<?php echo ($_v["id"]); ?> class="btn btn-success gps-complete" type="button">完成添加</button>
                            </td>
                        </tr><?php endforeach; endif; ?>
                    </table>
                </div>
                <?php echo ($page); ?>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $('.gps-complete').click(function(){
        var advanceId = $(this).attr('data-id');
        console.log(advanceId);

        $.ajax({
            type: "POST",
            url: "/index.php?s=/Admin/GPS/completeAllot",
            data: {
                advanceId:advanceId
            },
            success: function(msg){
                console.log(msg);
                if (msg) {
                    alert('该用户GPS设备已经分配完成');
                }
                window.location.reload();
           }
        });
    });
</script>